//
//  LFInforBaseController.m
//  ServiceBaZhou
//
//  Created by 刘江涛 on 2017/8/23.
//  Copyright © 2017年 weierda. All rights reserved.
//

#import "LFInforBaseController.h"

#import "LFInforCell.h"

//工商信息
#import "LFGSInforController.h"

//产品信息
#import "ProductController.h"

//裁判文书
#import "LFLawNoticeController.h"

//企业年报
#import "LFYearReportController.h"

//融资信息
#import "LFBusinessController.h"

//经营异常
#import "LFExceptionController.h"

//企业证书
#import "LFCerController.h"

//对外投资
#import "LFInvestController.h"

//商标查询
#import "LFTMController.h"

//著作权
#import "LFSoftwareController.h"

//公司历程
#import "LFHistoryController.h"

@interface LFInforBaseController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) NSArray *dataArray;

@property (nonatomic,strong) UITableView *tableView;

@end

@implementation LFInforBaseController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _dataArray = @[@"工商信息",@"公司产品",@"裁判文书",@"经营异常",@"融资信息",@"企业年报",@"对外投资",@"企业证书",@"公司历程",@"商标查询",@"著作权",@""];
    
    [self createNavigation:_model.Name];
    
    [self createTableView];
    
    [self createHeadView];
    
    [self createHeadView];
    
}

- (void)createTableView{
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, Width, Height - 64) style:UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    
    [_tableView registerNib:[UINib nibWithNibName:@"LFInforCell" bundle:nil] forCellReuseIdentifier:@"LFInforCell"];
    [self.view addSubview:_tableView];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 6;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    LFInforCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LFInforCell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    [cell.firstBtn addTarget:self action:@selector(cellBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    cell.firstBtn.tag = 1000 + 2 * indexPath.row;
    [cell.firstBtn setTitle:_dataArray[indexPath.row * 2] forState:UIControlStateNormal];
    
    [cell.lastBtn addTarget:self action:@selector(cellBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    cell.lastBtn.tag = 1000 + 2 * indexPath.row + 1;
    [cell.lastBtn setTitle:_dataArray[indexPath.row * 2 + 1] forState:UIControlStateNormal];
    
    return cell;
}

- (void)createHeadView{
    UIView *headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Width, 100)];
    headView.backgroundColor = [UIColor colorWithHexString:@"#168ec8"];
    
    NSArray *catagoryText = @[@"法定代表人",@"成立时间",@"注册号"];
    NSArray *inforText = @[_model.OperName,[_model.StartDate substringToIndex:10],_model.No];
    for (NSInteger i = 0; i < 3 ; i ++ ) {
        UILabel *catagoryLabel = [[UILabel alloc]initWithFrame:CGRectMake(Width/3 * i , 30, Width/3, 20)];
        catagoryLabel.text = catagoryText[i];
        catagoryLabel.textColor = [UIColor colorWithHexString:@"#C8C8C8"];
        catagoryLabel.font = [UIFont systemFontOfSize:11];
        catagoryLabel.textAlignment = NSTextAlignmentCenter;
        [headView addSubview:catagoryLabel];
        
        UILabel *inforLabel = [[UILabel alloc]initWithFrame:CGRectMake(Width/3*i, 50, Width/3, 30)];
        inforLabel.text = inforText[i];
        inforLabel.textColor = [UIColor whiteColor];
        inforLabel.font = [UIFont systemFontOfSize:13];
        inforLabel.textAlignment = NSTextAlignmentCenter;
        [headView addSubview:inforLabel];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(Width/3 * (i + 1), 45, 1, 20)];
        lineView.backgroundColor = [UIColor colorWithHexString:@"#C8C8C8"];
        [headView addSubview:lineView];
    }
    
    self.tableView.tableHeaderView = headView;
}

- (void)cellBtnClick:(UIButton *)button{
    
    
    LFGSInforController *gs = [[LFGSInforController alloc]init];
    ProductController *product = [[ProductController alloc]init];
    LFLawNoticeController *law = [[LFLawNoticeController alloc]init];
    LFYearReportController *report = [[LFYearReportController alloc]init];
    LFBusinessController *bussiness = [[LFBusinessController alloc]init];
    LFExceptionController *exception = [[LFExceptionController alloc]init];
    LFCerController *cer = [[LFCerController alloc]init];
    LFInvestController *invest = [[LFInvestController alloc]init];
    LFTMController *lftm = [[LFTMController alloc]init];
    LFHistoryController *history = [[LFHistoryController alloc]init];
    LFSoftwareController *software = [[LFSoftwareController alloc]init];
    
    switch (button.tag) {
        case 1000:
            //工商信息
            gs.titleText = _model.Name;
            gs.keyNo = _model.KeyNo;
            [self.navigationController pushViewController:gs animated:YES];
            break;
            
        case 1001:
            //公司产品
            product.keyNo = _model.Name;
            [self.navigationController pushViewController:product animated:YES];
            break;
            
        case 1002:
            //裁判文书
            law.companyName = _model.Name;
            [self.navigationController pushViewController:law animated:YES];
            break;
            
        case 1003:
            //经营异常
            exception.keyNo = _model.KeyNo;
            [self.navigationController pushViewController:exception animated:YES];
            break;
            
        case 1004:
            //融资信息
            bussiness.keyNo = _model.Name;
            [self.navigationController pushViewController:bussiness animated:YES];
            break;
            
        case 1005:
            //企业年报
            report.keyNo = _model.KeyNo;
            [self.navigationController pushViewController:report animated:YES];
            break;
            
        case 1006:
            //对外投资
            invest.company = _model.Name;
            [self.navigationController pushViewController:invest animated:YES];
            break;
            
        case 1007:
            //企业证书
            cer.companyName = _model.Name;
            [self.navigationController pushViewController:cer animated:YES];
            break;
            
        case 1008:
            //公司历程
            history.keyNo = _model.KeyNo;
            history.companyName = _model.Name;
            [self.navigationController pushViewController:history animated:YES];
            break;
            
        case 1009:
            //商标查询
            lftm.companyName = _model.Name;
            [self.navigationController pushViewController:lftm animated:YES];
            break;
            
        case 1010:
            //著作权
            software.companyName = _model.Name;
            [self.navigationController pushViewController:software animated:YES];
            break;
            
        default:
            break;
    }
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
